package com.tzy.shop.service;

import com.tzy.common.entity.Shop;
import com.tzy.shop.mapper.ShopMapper;
import com.tzy.shop.service.IShopService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 商家店铺表 服务实现类
 * </p>
 *
 * @author ljh
 * @since 2022-03-01
 */
@Service
public class ShopService extends ServiceImpl<ShopMapper, Shop> implements IShopService {
	@Resource
	private ShopMapper shopMapper;

	@Override
	@CacheEvict(value = {"list"})//清楚指定的缓存
	public boolean updateById(Shop entity) {
		return super.updateById(entity);
	}

	@Override
	@Cacheable(cacheNames = "list",unless = "false")//开启缓存
	public List<Shop> list() {
		return super.list();
	}

	@Override
	public boolean addShop(Shop shop) {
		int count = shopMapper.insert(shop);
		if (count >= 1){
			return true;
		}
		return false;
	}

	public Long getCount(){
		Long count = shopMapper.selectCount(null);
		return count;
	}


}
